package c.e.b.h.e.n;

import f.a0;
import f.c0;
import f.f0.c;
import f.r;
import f.t;
import f.u;
import f.u.a;
import f.v;
import f.x;
import f.y;
import f.z;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.concurrent.TimeUnit;

/* compiled from: HttpRequest */
public class b {
    public static final v f;
    public final a a;
    public final String b;
    public final Map<String, String> c;
    public final Map<String, String> d;
    public a e = null;

    static {
        f.v.b bVar = new f.v.b(new v(new f.v.b()));
        bVar.w = c.d("timeout", 10000, TimeUnit.MILLISECONDS);
        f = new v(bVar);
    }

    public b(a aVar, String str, Map<String, String> map) {
        this.a = aVar;
        this.b = str;
        this.c = map;
        this.d = new HashMap();
    }

    public d a() throws IOException {
        r b;
        z zVar;
        y.a aVar = new y.a();
        f.c.a aVar2 = new f.c.a();
        aVar2.a = true;
        String cVar = new f.c(aVar2).toString();
        String str = "Cache-Control";
        if (cVar.isEmpty()) {
            aVar.c.b(str);
        } else {
            aVar.c(str, cVar);
        }
        cVar = this.b;
        String str2 = null;
        try {
            r.a aVar3 = new r.a();
            aVar3.d(null, cVar);
            b = aVar3.b();
        } catch (IllegalArgumentException unused) {
            b = null;
        }
        r.a k = b.k();
        for (Entry entry : this.c.entrySet()) {
            k.a((String) entry.getKey(), (String) entry.getValue());
        }
        aVar.f(k.b());
        for (Entry entry2 : this.d.entrySet()) {
            aVar.c((String) entry2.getKey(), (String) entry2.getValue());
        }
        a aVar4 = this.e;
        if (aVar4 == null) {
            zVar = null;
        } else if (aVar4.c.isEmpty()) {
            throw new IllegalStateException("Multipart body must have at least one part.");
        } else {
            zVar = new u(aVar4.a, aVar4.b, aVar4.c);
        }
        aVar.d(this.a.name(), zVar);
        a0 b2 = ((x) f.a(aVar.b())).b();
        c0 c0Var = b2.g;
        if (c0Var != null) {
            str2 = c0Var.r();
        }
        return new d(b2.c, str2, b2.f);
    }

    public final a b() {
        if (this.e == null) {
            a aVar = new a();
            t tVar = u.f;
            Objects.requireNonNull(tVar, "type == null");
            if (tVar.b.equals("multipart")) {
                aVar.b = tVar;
                this.e = aVar;
            } else {
                StringBuilder stringBuilder = new StringBuilder();
                stringBuilder.append("multipart != ");
                stringBuilder.append(tVar);
                throw new IllegalArgumentException(stringBuilder.toString());
            }
        }
        return this.e;
    }

    public b c(String str, String str2) {
        a b = b();
        Objects.requireNonNull(b);
        b.c.add(f.u.b.a(str, null, z.create(null, str2)));
        this.e = b;
        return this;
    }

    public b d(String str, String str2, String str3, File file) {
        z create = z.create(t.b(str3), file);
        a b = b();
        Objects.requireNonNull(b);
        b.c.add(f.u.b.a(str, str2, create));
        this.e = b;
        return this;
    }
}
